package com.zdw.demo.controller;

import com.zdw.common.parent.JSONResult;
import com.zdw.demo.config.international.InternationalUtils;
import com.zdw.demo.dto.SeataDemoOneDto;
import com.zdw.demo.service.SeataDemoOneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 卓德文
 * @since 2022-11-21
 */
@RestController
@RequestMapping("/seataDemoOne")
@Api(value = "seata测试接口", tags = {"seataAPi"})
public class SeataDemoOneController {

    @Resource
    private SeataDemoOneService seataDemoOneService;

    /**
     * 测试seata分布式事务
     *
     * @param seataDemoOneDto
     * @return
     */
    @PostMapping("/testSeata")
    @ApiOperation("seata测试方法-testSeata")
    public JSONResult testSeata(@RequestBody @Valid SeataDemoOneDto seataDemoOneDto) {
        return new JSONResult().markSuccess(InternationalUtils.getInternational("common.success"), seataDemoOneService.insert(seataDemoOneDto));
    }

}
